package gui;

import processing.core.PApplet;

public class Plot extends Axes {
	double[] x;
	double[] y;
	int npts;
		
	public Plot(PApplet parentApplet, float[] r, double[] x, double[] y, Object... args) {
		super(parentApplet, r, x, y, args);
		this.x = x;
		this.y = y;
		npts = x.length;		
	}
		
	public void updateData(double[] x, double[] y) {
		updateAxes(x, y);
		this.x = x;
		this.y = y;
	}
		
	public void draw() {
        pa.fill(255);
		pa.noStroke();
		pa.rect(x0, y0, width, height);
		pa.stroke(0);
		float x1 = x2scr((float)x[0]);
		float y1 = y2scr((float)y[0]);
	    for (int i=1; i < npts; i++) {      
			float x2 = x2scr((float)x[i]);
			float y2 = y2scr((float)y[i]);
				            	            
		    pa.line(x1, y1, x2, y2);
	        x1 = x2;
	        y1 = y2;
        }
	    super.draw();
	}
		
}
